<div id="city-order-bar2" style=" height: 100%">

</div>
<script type="text/javascript">
    $(function () {
        load();
        $("select#prjId").change(function(){
            load();
        });
    });
    function load() {
        var slelect=$("#prjId").val();
        $.ajax({
            url: "#springUrl('/network/city/department/bar1')",
            data: {"batchId": "59","select":slelect},
            type: "POST",
            success: function (text) {
                var d = JSON.parse(text);
                if (d.success && d.data) {
                    var myChart = echarts.init(document.getElementById('city-order-bar2'), 'macarons');
                    option = {
                        title : {

                            x:'center'
                        },
                        tooltip : {
                            trigger: 'item',
                            formatter: "{a} <br/>{b} : {c} ({d}%)"
                        },
                        legend: {
                            //orient: 'vertical',
                            x : 'center',
                            y : 270,
                            data: d.data.x,
                        },
                        toolbox: {
                            feature: {

                            }
                        },
                        series : [
                            {
                                name: '',
                                type: 'pie',
                                radius : '55%',
                                center: ['50%', '40%'],
                                data:d.data.series1,
                                itemStyle: {
                                    emphasis: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    },
                                    normal: {
                                        //好，这里就是重头戏了，定义一个list，然后根据所以取得不同的值，这样就实现了，
                                        color: function(params) {
                                            // build a color map as your need.
                                            var colorList = [
                                                '#0fa99d','#d9d9d9','#4472c4'
                                            ];
                                            return colorList[params.dataIndex]
                                        },
                                        //以下为是否显示，显示位置和显示格式的设置了
                                    }
                                }
                            }
                        ]
                    };

                    myChart.setOption(option);
                }
            },
            error:function (text) {
                var div1="<div type='text' style='padding-top:15%' class=' text-center  '>查询数据异常</div>";
                $("#bar2").empty();
                $("#bar2").prepend(div1);
            }
        })
    };
</script>
